package com.sws.yygh.hosp.controller;

import com.sws.yygh.common.result.Result;
import com.sws.yygh.hosp.service.HospitalService;
import com.sws.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: Appointment-hospital-registration-system
 * @description:
 * @author:
 * @create: 2022-07-18 23:28
 */
@Api(tags = "医院管理接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    HospitalService hospitalService;

    @ApiOperation(value = "条件查询分页")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Integer page,
                           @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Integer limit,
                           @ApiParam(name = "hospitalQueryVo", value = "查询对象", required = false) HospitalQueryVo hospitalQueryVo){
        return Result.ok(hospitalService.selectPage(page,limit,hospitalQueryVo));
    }

    @ApiOperation(value = "更新上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateStatus (@ApiParam(name = "id", value = "医院id", required = true)
                                    @PathVariable(value = "id") String id,
                                @ApiParam(name = "status", value = "状态（0：未上线 1：已上线）", required = true)
                                @PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
       return Result.ok();
    }

    @ApiOperation("医院详情查看")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@ApiParam(name = "id", value = "医院id", required = true)
                                     @PathVariable String id){
        return Result.ok(hospitalService.show(id));

    }
}
